package com.snailhd.entity;

import lombok.*;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;

/**
 * 实时数据
 * @author hd
 * @date 2019-11-24 16:17
 */

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor

@CompoundIndexes({
        @CompoundIndex(name = "uniq_code_time", def = "{'symbol' : 1, 'time': 1}",unique=true)
})
public class StockRealTime extends StockDay {

    private String symbol;

    private String time;

    private StockRealTimeBet[] buyBets = new StockRealTimeBet[5];

    private StockRealTimeBet[] sellBets = new StockRealTimeBet[5];


    public void saveBuyBet(StockRealTimeBet bet){
        bet.setType(StockRealTimeBet.Type.BUY);
        buyBets[bet.getLevel()-1] = bet;
    }

    public void saveSellBet(StockRealTimeBet bet){
        bet.setType(StockRealTimeBet.Type.SELL);
        buyBets[bet.getLevel()-1] = bet;
    }
}
